import pygame
import threading
import random
import math
class Arrow():
    def __init__(self,screen,bow,alpha):#alpha是出射角
        self.screen=screen        
        self.image=pygame.image.load('arrow.png').convert()
        self.rect=self.image.get_rect()
        self.rect.centerx=bow.rect.centerx
        self.rect.centery=bow.rect.centery
        self.alpha=alpha  #箭头的角度
        self.dirx=round(20*math.cos(math.radians(alpha)))
        self.diry=round(20*math.sin(math.radians(alpha)))

    def fly(self):
         self.rect.centerx+=self.dirx
         self.rect.centery-=self.diry #注意和传统坐标系的区别

    def IsOut(self):
        if (self.rect.centerx>900 or self.rect.centerx<-100 or \
            self.rect.centery>700 or self.rect.centery<-100):
            return True
        else:
            return False
        
        
